home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / os2 / adaptor.zip / ADAPT.ZIP / adaptor / src / include / permutat.h < prev    next >
Text File  |  1993-07-08  |  6KB  |  130 lines

  1. /*********************************************************************
  2. *                                                                    *
  3. *  Author      : Dr. Thomas Brandes, GMD, I1.HR                      *
  4. *  Date        : Mar 93                                              *
  5. *  Last Update : Mar 93                                              *
  6. *                                                                    *
  7. *  Module      : permutations.c                                      *
  8. *                                                                    *
  9. *********************************************************************/
  10.  
  11. # if defined __STDC__ | defined __cplusplus
  12. # define ARGS(parameters)       parameters
  13. # else
  14. # define ARGS(parameters)       ()
  15. # endif
  16.  
  17. # include "Tree.h"
  18.  
  19.        /*************************************************
  20.        *                                                *
  21.        *  Type definition for a Permutation             *
  22.        *                                                *
  23.        *    1  -> Permutation.pa[0]                     *
  24.        *    2  -> Permutation.pa[1]                     *
  25.        *                                                *
  26.        *    n  -> Permutation.pa[n-1]                   *
  27.        *                                                *
  28.        *   where n is Permutation.n                     *
  29.        *                                                *
  30.        *************************************************/
  31.  
  32. typedef struct {
  33.   int n; 
  34.   int pa [MAX_DIMENSIONS];
  35.   }  Permutation;
  36.  
  37.        /*************************************************
  38.        *                                                *
  39.        *  some operations on Permutations               *
  40.        *                                                *
  41.        *  make_id_permuatation (5)  :  1 2 3 4 5        *
  42.        *                                                *
  43.        *************************************************/
  44.  
  45. Permutation make_id_permutation ARGS((int n));
  46.  
  47. bool is_id_permutation ARGS((Permutation perm));
  48.  
  49. int new_perm_position ARGS((Permutation perm, int pos));
  50.  
  51.        /****************************************************
  52.        *                                                   *
  53.        *       1  2  3  4  5                               *
  54.        *  p :  3  4  5  2  1                               *
  55.        *                                                   *
  56.        *   olddim = 4     newdim = 2                       *
  57.        *                                                   *
  58.        *  n :  3  4  2  1                                  *
  59.        *                                                   *
  60.        ****************************************************/
  61.  
  62. Permutation reduce_permutation ARGS((Permutation p, int olddim, int newdim));
  63.  
  64. bool equal_permutations ARGS((Permutation perm1, Permutation perm2));
  65.  
  66. bool conform_permutations ARGS((Permutation perm1, Permutation perm2));
  67.  
  68. bool transpose_permutations ARGS((Permutation perm1, Permutation perm2));
  69.  
  70. Permutation merge_permutation ARGS((Permutation perm1, Permutation perm2));
  71.  
  72. void print_permutation ARGS((Permutation perm));
  73.  
  74.        /****************************************************
  75.        *                                                   *
  76.        *  make permutation from the current distribution   *
  77.        *                                                   *
  78.        *  A (N1,N2,N3,N4,N5)  (*,BLOCK,*,BLOCK,*)          *
  79.        *                                                   *
  80.        *  ->      1, 3, 5, 2, 4                            *
  81.        *                                                   *
  82.        ****************************************************/
  83.  
  84. Permutation implied_distribution_permutation ARGS((DistributedDimensions dist));
  85.  
  86.        /****************************************************
  87.        *                                                   *
  88.        *  index_list returns a sequence of ranks of index  *
  89.        *                                                   *
  90.        *  [1:n,A,I,J,B] ->  1  2  0  0  3                  *
  91.        *                                                   *
  92.        ****************************************************/
  93.  
  94. Permutation index_list ARGS((tTree indexes));
  95.  
  96.  
  97.        /****************************************************
  98.        *                                                   *
  99.        *  get_rank_permutation :                           *
  100.        *                                                   *
  101.        *  index_vector  :   1  0  2  0  3                  *
  102.        *  perm          :   4  1  5  2  3                  *
  103.        *                                                   *
  104.        *  results in    :   0  1  3  0  2                  *
  105.        *                                                   *
  106.        *  compressed    :   1  3  2  0  0                  *
  107.        *                                                   *
  108.        ****************************************************/
  109.  
  110. Permutation get_rank_permutation ARGS((Permutation index_vector, 
  111.                                            Permutation perm));
  112.  
  113.        /****************************************************
  114.        *                                                   *
  115.        *  switch_index_types :                             *
  116.        *  switch_indexes     :                             *
  117.        *                                                   *
  118.        *     perm = 4  2  3  1  5                          *
  119.        *                                                   *
  120.        *  (N1,N2,N3,N4,N5)  -> (N4,N2,N3,N1,N5)            *
  121.        *                                                   *
  122.        ****************************************************/
  123.  
  124. void switch_index_types ARGS((tTree typelist, Permutation perm));
  125.  
  126. void switch_indexes ARGS((tTree indexlist, Permutation perm));
  127.  
  128. void switch_parameters ARGS((tTree paramlist, Permutation perm));
  129.  
  130.